from selenium.webdriver.common.by import By

from v7.base.base_actions import BaseAction


class LoginPages(BaseAction):

    # 用户名输入框元素
    # 这种是一种语法格式, 打包成一个元组
    username_input = By.ID, "username"

    # 密码输入框
    password_input = By.ID, "password"

    # 验证码输入框
    verify_code_input = By.ID, "verify_code"

    # 登录按钮
    login_btn = By.CLASS_NAME, "J-login-submit"

    # 1.进入登录页面, 输入一个不存在的用户名
    def input_username(self, username):
        self.input(self.username_input, username)

    # 2.输入密码
    def input_password(self, password):
        self.input(self.password_input, password)

    # 3.输入验证码
    def input_verify_code(self, code):
        self.input(self.verify_code_input, code)

    # 4.点击登录按钮
    def click_login_btn(self):
        self.click(self.login_btn)

    # 5.获取错误提示信息
    def get_msg(self):
        return self.driver.find_element(By.CLASS_NAME, "layui-layer-content").text